Skip to content

feat(tvf): collect transaction hashes for stellar_signXDR and stellar_signAndSubmitXDR - #346

Open
jakubuid wants to merge 1 commit into
developfrom
feat/stellar-tvf
Open

feat(tvf): collect transaction hashes for stellar_signXDR and stellar_signAndSubmitXDR#346
jakubuid wants to merge 1 commit into
developfrom
feat/stellar-tvf

Conversation

@jakubuid

Copy link
Copy Markdown
Collaborator

Description

Swift port of WalletConnect/walletconnect-monorepo#7318 — adds Stellar to TVF transaction-hash collection per the Stellar RPC proposal. Sibling PR: reown-com/reown-kotlin#426.

Method Strategy
stellar_signAndSubmitXDR Response contains the hash — extracted from tx_hash
stellar_signXDR Response contains only signedXDR — hash computed client-side

Hash computation (StellarTVFCollector)

sha256(network_id ‖ envelope_type ‖ transaction_body) from the base64 TransactionEnvelope XDR:

  1. read the 4-byte envelope discriminant — V0 / V1 / fee-bump all supported
  2. locate the trailing DecoratedSignature<20> array with a validated scan (fixed 72-byte ed25519 entries) — no full XDR schema parsing
  3. network passphrase selected from the request's CAIP-2 chain param, defaulting to pubnet

No new dependencies — CryptoKit SHA256 + Foundation base64, same as the Cosmos collector.

Tests

8 cases in StellarTVFCollectorTests using real Horizon transactions (byte-identical vectors to the JS/Kotlin PRs): pubnet V1 (QA-verified against Stellar Lab), pubnet fee-bump → canonical hash, testnet, default-to-pubnet, tx_hash extraction (the on-chain hash from the E2E wallet QA run), malformed envelope → nil, error result → nil, method support.

xcodebuild test -scheme WalletConnect -only-testing:RelayerTests/StellarTVFCollectorTestsExecuted 8 tests, with 0 failures. TEST SUCCEEDED.

QA context

The same algorithm was E2E-verified via react-dapp-v2 → react-wallet-v2 with the JS SDK build: signAndSubmitXDR hash confirmed on-chain (stellarchain.io), signXDR hash confirmed against Stellar Lab's independent computation.

🤖 Generated with Claude Code

…_signAndSubmitXDR

Swift port of WalletConnect/walletconnect-monorepo#7318.

- stellar_signAndSubmitXDR: extract tx_hash from the wallet response.
- stellar_signXDR: compute the hash dependency-free from the base64
  TransactionEnvelope XDR as sha256(network_id || envelope_type ||
  transaction_body) via CryptoKit. Supports V0, V1 and fee-bump
  envelopes; the trailing DecoratedSignature array is located by a
  validated scan rather than parsing the full transaction schema.
  Network passphrase is selected from the request's CAIP-2 chain
  param (defaults to pubnet).

Test vectors are real pubnet/testnet transactions fetched from Horizon,
identical to the vectors in the JS and Kotlin PRs.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@claude

claude Bot commented Aug 17, 2026

Copy link
Copy Markdown

Claude finished @jakubuid's task in 3m 40s —— View job


Code Review Complete

Tasks

  • Read StellarTVFCollector.swift implementation
  • Read TVFCollector.swift changes
  • Read StellarTVFCollectorTests.swift test suite
  • Analyze cryptographic implementation
  • Check XDR parsing logic for edge cases
  • Review error handling
  • Run automated security checks
  • Post findings

Review Summary

✅ No issues found

Automated Checks

✅ No external domain URLs detected
✅ No cache-control issues detected
✅ No workflow security issues detected


Reviewed 3 files:

  • StellarTVFCollector.swift: Cryptographic hash computation verified safe, bounds checking adequate, proper error handling
  • TVFCollector.swift: Integration point correct
  • StellarTVFCollectorTests.swift: Comprehensive test coverage (8 test cases, real Horizon transactions)

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
C Security Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

static let STELLAR_SIGN_XDR = "stellar_signXDR"
static let STELLAR_SIGN_AND_SUBMIT_XDR = "stellar_signAndSubmitXDR"

private static let pubnetPassphrase = "Public Global Stellar Network ; September 2015"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants